/**
 * openHAB, the open Home Automation Bus.
 * Copyright (C) 2011, openHAB.org <admin@openhab.org>
 *
 * See the contributors.txt file in the distribution for a
 * full listing of individual contributors.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses>.
 *
 * Additional permission under GNU GPL version 3 section 7
 *
 * If you modify this Program, or any covered work, by linking or
 * combining it with Eclipse (or a modified version of that library),
 * containing parts covered by the terms of the Eclipse Public License
 * (EPL), the licensors of this Program grant you additional permission
 * to convey the resulting work.
 */

/*
* generated by Xtext
*/
package org.openhab.model.parseTreeConstruction;

import org.eclipse.emf.ecore.*;
import org.eclipse.xtext.*;
import org.eclipse.xtext.parsetree.reconstr.IEObjectConsumer;
import org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor;

import org.openhab.model.services.ItemsGrammarAccess;

import com.google.inject.Inject;

@SuppressWarnings("all")
public class ItemsParsetreeConstructor extends AbstractParseTreeConstructor {
		
	@Inject
	private ItemsGrammarAccess grammarAccess;
	
	@Override
	protected AbstractToken getRootToken(IEObjectConsumer inst) {
		return new ThisRootNode(inst);	
	}
	
protected class ThisRootNode extends RootToken {
	public ThisRootNode(IEObjectConsumer inst) {
		super(inst);
	}
	
	@Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new ItemModel_ItemsAssignment(this, this, 0, inst);
			case 1: return new Item_Group(this, this, 1, inst);
			case 2: return new GroupItem_Group(this, this, 2, inst);
			case 3: return new NormalItem_TypeAssignment(this, this, 3, inst);
			case 4: return new Binding_Group(this, this, 4, inst);
			default: return null;
		}	
	}	
}
	

/************ begin Rule ItemModel ****************
 *
 * ItemModel:
 * 	items+=Item*;
 *
 **/

// items+=Item*
protected class ItemModel_ItemsAssignment extends AssignmentToken  {
	
	public ItemModel_ItemsAssignment(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Assignment getGrammarElement() {
		return grammarAccess.getItemModelAccess().getItemsAssignment();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_Group(this, this, 0, inst);
			default: return null;
		}	
	}

    @Override	
	public IEObjectConsumer tryConsume() {
		if((value = eObjectConsumer.getConsumable("items",false)) == null) return null;
		IEObjectConsumer obj = eObjectConsumer.cloneAndConsume("items");
		if(value instanceof EObject) { // org::eclipse::xtext::impl::RuleCallImpl
			IEObjectConsumer param = createEObjectConsumer((EObject)value);
			if(param.isInstanceOf(grammarAccess.getItemRule().getType().getClassifier())) {
				type = AssignmentType.PARSER_RULE_CALL;
				element = grammarAccess.getItemModelAccess().getItemsItemParserRuleCall_0(); 
				consumed = obj;
				return param;
			}
		}
		return null;
	}

    @Override
	public AbstractToken createFollowerAfterReturn(AbstractToken next,	int actIndex, int index, IEObjectConsumer inst) {
		if(value == inst.getEObject() && !inst.isConsumed()) return null;
		switch(index) {
			case 0: return new ItemModel_ItemsAssignment(lastRuleCallOrigin, next, actIndex, consumed);
			default: return lastRuleCallOrigin.createFollowerAfterReturn(next, actIndex , index - 1, consumed);
		}	
	}	
}

/************ end Rule ItemModel ****************/


/************ begin Rule Item ****************
 *
 * Item:
 * 	(NormalItem | GroupItem) name=ID label=STRING? ("<" icon=(ID | STRING) ">")? ("(" groups+=[GroupItem] (","
 * 	groups+=[GroupItem])* ")")? ("{" bindings+=Binding ("," bindings+=Binding)* "}")*;
 *
 **/

// (NormalItem | GroupItem) name=ID label=STRING? ("<" icon=(ID | STRING) ">")? ("(" groups+=[GroupItem] (","
// groups+=[GroupItem])* ")")? ("{" bindings+=Binding ("," bindings+=Binding)* "}")*
protected class Item_Group extends GroupToken {
	
	public Item_Group(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Group getGrammarElement() {
		return grammarAccess.getItemAccess().getGroup();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_Group_5(lastRuleCallOrigin, this, 0, inst);
			case 1: return new Item_Group_4(lastRuleCallOrigin, this, 1, inst);
			case 2: return new Item_Group_3(lastRuleCallOrigin, this, 2, inst);
			case 3: return new Item_LabelAssignment_2(lastRuleCallOrigin, this, 3, inst);
			case 4: return new Item_NameAssignment_1(lastRuleCallOrigin, this, 4, inst);
			default: return null;
		}	
	}

    @Override
	public IEObjectConsumer tryConsume() {
		if(getEObject().eClass() != grammarAccess.getGroupItemAccess().getGroupAction_1().getType().getClassifier() && 
		   getEObject().eClass() != grammarAccess.getNormalItemRule().getType().getClassifier())
			return null;
		return eObjectConsumer;
	}

}

// NormalItem | GroupItem
protected class Item_Alternatives_0 extends AlternativesToken {

	public Item_Alternatives_0(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Alternatives getGrammarElement() {
		return grammarAccess.getItemAccess().getAlternatives_0();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_NormalItemParserRuleCall_0_0(lastRuleCallOrigin, this, 0, inst);
			case 1: return new Item_GroupItemParserRuleCall_0_1(lastRuleCallOrigin, this, 1, inst);
			default: return null;
		}	
	}

}

// NormalItem
protected class Item_NormalItemParserRuleCall_0_0 extends RuleCallToken {
	
	public Item_NormalItemParserRuleCall_0_0(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public RuleCall getGrammarElement() {
		return grammarAccess.getItemAccess().getNormalItemParserRuleCall_0_0();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new NormalItem_TypeAssignment(this, this, 0, inst);
			default: return null;
		}	
	}

    @Override
	public IEObjectConsumer tryConsume() {
		if(getEObject().eClass() != grammarAccess.getNormalItemRule().getType().getClassifier())
			return null;
		if(checkForRecursion(NormalItem_TypeAssignment.class, eObjectConsumer)) return null;
		return eObjectConsumer;
	}
	
    @Override
	public AbstractToken createFollowerAfterReturn(AbstractToken next,	int actIndex, int index, IEObjectConsumer inst) {
		switch(index) {
			default: return lastRuleCallOrigin.createFollowerAfterReturn(next, actIndex , index, inst);
		}	
	}	
}

// GroupItem
protected class Item_GroupItemParserRuleCall_0_1 extends RuleCallToken {
	
	public Item_GroupItemParserRuleCall_0_1(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public RuleCall getGrammarElement() {
		return grammarAccess.getItemAccess().getGroupItemParserRuleCall_0_1();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new GroupItem_Group(this, this, 0, inst);
			default: return null;
		}	
	}

    @Override
	public IEObjectConsumer tryConsume() {
		if(getEObject().eClass() != grammarAccess.getGroupItemAccess().getGroupAction_1().getType().getClassifier())
			return null;
		if(checkForRecursion(GroupItem_Group.class, eObjectConsumer)) return null;
		return eObjectConsumer;
	}
	
    @Override
	public AbstractToken createFollowerAfterReturn(AbstractToken next,	int actIndex, int index, IEObjectConsumer inst) {
		switch(index) {
			default: return lastRuleCallOrigin.createFollowerAfterReturn(next, actIndex , index, inst);
		}	
	}	
}


// name=ID
protected class Item_NameAssignment_1 extends AssignmentToken  {
	
	public Item_NameAssignment_1(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Assignment getGrammarElement() {
		return grammarAccess.getItemAccess().getNameAssignment_1();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_Alternatives_0(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

    @Override	
	public IEObjectConsumer tryConsume() {
		if((value = eObjectConsumer.getConsumable("name",true)) == null) return null;
		IEObjectConsumer obj = eObjectConsumer.cloneAndConsume("name");
		if(valueSerializer.isValid(obj.getEObject(), grammarAccess.getItemAccess().getNameIDTerminalRuleCall_1_0(), value, null)) {
			type = AssignmentType.TERMINAL_RULE_CALL;
			element = grammarAccess.getItemAccess().getNameIDTerminalRuleCall_1_0();
			return obj;
		}
		return null;
	}

}

// label=STRING?
protected class Item_LabelAssignment_2 extends AssignmentToken  {
	
	public Item_LabelAssignment_2(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Assignment getGrammarElement() {
		return grammarAccess.getItemAccess().getLabelAssignment_2();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_NameAssignment_1(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

    @Override	
	public IEObjectConsumer tryConsume() {
		if((value = eObjectConsumer.getConsumable("label",false)) == null) return null;
		IEObjectConsumer obj = eObjectConsumer.cloneAndConsume("label");
		if(valueSerializer.isValid(obj.getEObject(), grammarAccess.getItemAccess().getLabelSTRINGTerminalRuleCall_2_0(), value, null)) {
			type = AssignmentType.TERMINAL_RULE_CALL;
			element = grammarAccess.getItemAccess().getLabelSTRINGTerminalRuleCall_2_0();
			return obj;
		}
		return null;
	}

}

// ("<" icon=(ID | STRING) ">")?
protected class Item_Group_3 extends GroupToken {
	
	public Item_Group_3(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Group getGrammarElement() {
		return grammarAccess.getItemAccess().getGroup_3();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_GreaterThanSignKeyword_3_2(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

}

// "<"
protected class Item_LessThanSignKeyword_3_0 extends KeywordToken  {
	
	public Item_LessThanSignKeyword_3_0(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Keyword getGrammarElement() {
		return grammarAccess.getItemAccess().getLessThanSignKeyword_3_0();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_LabelAssignment_2(lastRuleCallOrigin, this, 0, inst);
			case 1: return new Item_NameAssignment_1(lastRuleCallOrigin, this, 1, inst);
			default: return null;
		}	
	}

}

// icon=(ID | STRING)
protected class Item_IconAssignment_3_1 extends AssignmentToken  {
	
	public Item_IconAssignment_3_1(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Assignment getGrammarElement() {
		return grammarAccess.getItemAccess().getIconAssignment_3_1();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_LessThanSignKeyword_3_0(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

    @Override	
	public IEObjectConsumer tryConsume() {
		if((value = eObjectConsumer.getConsumable("icon",false)) == null) return null;
		IEObjectConsumer obj = eObjectConsumer.cloneAndConsume("icon");
		if(valueSerializer.isValid(obj.getEObject(), grammarAccess.getItemAccess().getIconIDTerminalRuleCall_3_1_0_0(), value, null)) {
			type = AssignmentType.TERMINAL_RULE_CALL;
			element = grammarAccess.getItemAccess().getIconIDTerminalRuleCall_3_1_0_0();
			return obj;
		}
		if(valueSerializer.isValid(obj.getEObject(), grammarAccess.getItemAccess().getIconSTRINGTerminalRuleCall_3_1_0_1(), value, null)) {
			type = AssignmentType.TERMINAL_RULE_CALL;
			element = grammarAccess.getItemAccess().getIconSTRINGTerminalRuleCall_3_1_0_1();
			return obj;
		}
		return null;
	}

}

// ">"
protected class Item_GreaterThanSignKeyword_3_2 extends KeywordToken  {
	
	public Item_GreaterThanSignKeyword_3_2(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Keyword getGrammarElement() {
		return grammarAccess.getItemAccess().getGreaterThanSignKeyword_3_2();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_IconAssignment_3_1(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

}


// ("(" groups+=[GroupItem] ("," groups+=[GroupItem])* ")")?
protected class Item_Group_4 extends GroupToken {
	
	public Item_Group_4(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Group getGrammarElement() {
		return grammarAccess.getItemAccess().getGroup_4();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_RightParenthesisKeyword_4_3(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

}

// "("
protected class Item_LeftParenthesisKeyword_4_0 extends KeywordToken  {
	
	public Item_LeftParenthesisKeyword_4_0(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Keyword getGrammarElement() {
		return grammarAccess.getItemAccess().getLeftParenthesisKeyword_4_0();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_Group_3(lastRuleCallOrigin, this, 0, inst);
			case 1: return new Item_LabelAssignment_2(lastRuleCallOrigin, this, 1, inst);
			case 2: return new Item_NameAssignment_1(lastRuleCallOrigin, this, 2, inst);
			default: return null;
		}	
	}

}

// groups+=[GroupItem]
protected class Item_GroupsAssignment_4_1 extends AssignmentToken  {
	
	public Item_GroupsAssignment_4_1(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Assignment getGrammarElement() {
		return grammarAccess.getItemAccess().getGroupsAssignment_4_1();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_LeftParenthesisKeyword_4_0(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

    @Override	
	public IEObjectConsumer tryConsume() {
		if((value = eObjectConsumer.getConsumable("groups",true)) == null) return null;
		IEObjectConsumer obj = eObjectConsumer.cloneAndConsume("groups");
		if(value instanceof EObject) { // org::eclipse::xtext::impl::CrossReferenceImpl
			IEObjectConsumer param = createEObjectConsumer((EObject)value);
			if(param.isInstanceOf(grammarAccess.getItemAccess().getGroupsGroupItemCrossReference_4_1_0().getType().getClassifier())) {
				type = AssignmentType.CROSS_REFERENCE;
				element = grammarAccess.getItemAccess().getGroupsGroupItemCrossReference_4_1_0(); 
				return obj;
			}
		}
		return null;
	}

}

// ("," groups+=[GroupItem])*
protected class Item_Group_4_2 extends GroupToken {
	
	public Item_Group_4_2(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Group getGrammarElement() {
		return grammarAccess.getItemAccess().getGroup_4_2();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_GroupsAssignment_4_2_1(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

}

// ","
protected class Item_CommaKeyword_4_2_0 extends KeywordToken  {
	
	public Item_CommaKeyword_4_2_0(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Keyword getGrammarElement() {
		return grammarAccess.getItemAccess().getCommaKeyword_4_2_0();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_Group_4_2(lastRuleCallOrigin, this, 0, inst);
			case 1: return new Item_GroupsAssignment_4_1(lastRuleCallOrigin, this, 1, inst);
			default: return null;
		}	
	}

}

// groups+=[GroupItem]
protected class Item_GroupsAssignment_4_2_1 extends AssignmentToken  {
	
	public Item_GroupsAssignment_4_2_1(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Assignment getGrammarElement() {
		return grammarAccess.getItemAccess().getGroupsAssignment_4_2_1();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_CommaKeyword_4_2_0(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

    @Override	
	public IEObjectConsumer tryConsume() {
		if((value = eObjectConsumer.getConsumable("groups",false)) == null) return null;
		IEObjectConsumer obj = eObjectConsumer.cloneAndConsume("groups");
		if(value instanceof EObject) { // org::eclipse::xtext::impl::CrossReferenceImpl
			IEObjectConsumer param = createEObjectConsumer((EObject)value);
			if(param.isInstanceOf(grammarAccess.getItemAccess().getGroupsGroupItemCrossReference_4_2_1_0().getType().getClassifier())) {
				type = AssignmentType.CROSS_REFERENCE;
				element = grammarAccess.getItemAccess().getGroupsGroupItemCrossReference_4_2_1_0(); 
				return obj;
			}
		}
		return null;
	}

}


// ")"
protected class Item_RightParenthesisKeyword_4_3 extends KeywordToken  {
	
	public Item_RightParenthesisKeyword_4_3(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Keyword getGrammarElement() {
		return grammarAccess.getItemAccess().getRightParenthesisKeyword_4_3();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_Group_4_2(lastRuleCallOrigin, this, 0, inst);
			case 1: return new Item_GroupsAssignment_4_1(lastRuleCallOrigin, this, 1, inst);
			default: return null;
		}	
	}

}


// ("{" bindings+=Binding ("," bindings+=Binding)* "}")*
protected class Item_Group_5 extends GroupToken {
	
	public Item_Group_5(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Group getGrammarElement() {
		return grammarAccess.getItemAccess().getGroup_5();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_RightCurlyBracketKeyword_5_3(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

}

// "{"
protected class Item_LeftCurlyBracketKeyword_5_0 extends KeywordToken  {
	
	public Item_LeftCurlyBracketKeyword_5_0(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Keyword getGrammarElement() {
		return grammarAccess.getItemAccess().getLeftCurlyBracketKeyword_5_0();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_Group_5(lastRuleCallOrigin, this, 0, inst);
			case 1: return new Item_Group_4(lastRuleCallOrigin, this, 1, inst);
			case 2: return new Item_Group_3(lastRuleCallOrigin, this, 2, inst);
			case 3: return new Item_LabelAssignment_2(lastRuleCallOrigin, this, 3, inst);
			case 4: return new Item_NameAssignment_1(lastRuleCallOrigin, this, 4, inst);
			default: return null;
		}	
	}

}

// bindings+=Binding
protected class Item_BindingsAssignment_5_1 extends AssignmentToken  {
	
	public Item_BindingsAssignment_5_1(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Assignment getGrammarElement() {
		return grammarAccess.getItemAccess().getBindingsAssignment_5_1();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Binding_Group(this, this, 0, inst);
			default: return null;
		}	
	}

    @Override	
	public IEObjectConsumer tryConsume() {
		if((value = eObjectConsumer.getConsumable("bindings",true)) == null) return null;
		IEObjectConsumer obj = eObjectConsumer.cloneAndConsume("bindings");
		if(value instanceof EObject) { // org::eclipse::xtext::impl::RuleCallImpl
			IEObjectConsumer param = createEObjectConsumer((EObject)value);
			if(param.isInstanceOf(grammarAccess.getBindingRule().getType().getClassifier())) {
				type = AssignmentType.PARSER_RULE_CALL;
				element = grammarAccess.getItemAccess().getBindingsBindingParserRuleCall_5_1_0(); 
				consumed = obj;
				return param;
			}
		}
		return null;
	}

    @Override
	public AbstractToken createFollowerAfterReturn(AbstractToken next,	int actIndex, int index, IEObjectConsumer inst) {
		if(value == inst.getEObject() && !inst.isConsumed()) return null;
		switch(index) {
			case 0: return new Item_LeftCurlyBracketKeyword_5_0(lastRuleCallOrigin, next, actIndex, consumed);
			default: return null;
		}	
	}	
}

// ("," bindings+=Binding)*
protected class Item_Group_5_2 extends GroupToken {
	
	public Item_Group_5_2(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Group getGrammarElement() {
		return grammarAccess.getItemAccess().getGroup_5_2();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_BindingsAssignment_5_2_1(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

}

// ","
protected class Item_CommaKeyword_5_2_0 extends KeywordToken  {
	
	public Item_CommaKeyword_5_2_0(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Keyword getGrammarElement() {
		return grammarAccess.getItemAccess().getCommaKeyword_5_2_0();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_Group_5_2(lastRuleCallOrigin, this, 0, inst);
			case 1: return new Item_BindingsAssignment_5_1(lastRuleCallOrigin, this, 1, inst);
			default: return null;
		}	
	}

}

// bindings+=Binding
protected class Item_BindingsAssignment_5_2_1 extends AssignmentToken  {
	
	public Item_BindingsAssignment_5_2_1(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Assignment getGrammarElement() {
		return grammarAccess.getItemAccess().getBindingsAssignment_5_2_1();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Binding_Group(this, this, 0, inst);
			default: return null;
		}	
	}

    @Override	
	public IEObjectConsumer tryConsume() {
		if((value = eObjectConsumer.getConsumable("bindings",false)) == null) return null;
		IEObjectConsumer obj = eObjectConsumer.cloneAndConsume("bindings");
		if(value instanceof EObject) { // org::eclipse::xtext::impl::RuleCallImpl
			IEObjectConsumer param = createEObjectConsumer((EObject)value);
			if(param.isInstanceOf(grammarAccess.getBindingRule().getType().getClassifier())) {
				type = AssignmentType.PARSER_RULE_CALL;
				element = grammarAccess.getItemAccess().getBindingsBindingParserRuleCall_5_2_1_0(); 
				consumed = obj;
				return param;
			}
		}
		return null;
	}

    @Override
	public AbstractToken createFollowerAfterReturn(AbstractToken next,	int actIndex, int index, IEObjectConsumer inst) {
		if(value == inst.getEObject() && !inst.isConsumed()) return null;
		switch(index) {
			case 0: return new Item_CommaKeyword_5_2_0(lastRuleCallOrigin, next, actIndex, consumed);
			default: return null;
		}	
	}	
}


// "}"
protected class Item_RightCurlyBracketKeyword_5_3 extends KeywordToken  {
	
	public Item_RightCurlyBracketKeyword_5_3(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Keyword getGrammarElement() {
		return grammarAccess.getItemAccess().getRightCurlyBracketKeyword_5_3();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Item_Group_5_2(lastRuleCallOrigin, this, 0, inst);
			case 1: return new Item_BindingsAssignment_5_1(lastRuleCallOrigin, this, 1, inst);
			default: return null;
		}	
	}

}



/************ end Rule Item ****************/


/************ begin Rule GroupItem ****************
 *
 * GroupItem:
 * 	"Group" {Group};
 *
 **/

// "Group" {Group}
protected class GroupItem_Group extends GroupToken {
	
	public GroupItem_Group(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Group getGrammarElement() {
		return grammarAccess.getGroupItemAccess().getGroup();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new GroupItem_GroupAction_1(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

    @Override
	public IEObjectConsumer tryConsume() {
		if(getEObject().eClass() != grammarAccess.getGroupItemAccess().getGroupAction_1().getType().getClassifier())
			return null;
		return eObjectConsumer;
	}

}

// "Group"
protected class GroupItem_GroupKeyword_0 extends KeywordToken  {
	
	public GroupItem_GroupKeyword_0(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Keyword getGrammarElement() {
		return grammarAccess.getGroupItemAccess().getGroupKeyword_0();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			default: return lastRuleCallOrigin.createFollowerAfterReturn(this, index, index, inst);
		}	
	}

}

// {Group}
protected class GroupItem_GroupAction_1 extends ActionToken  {

	public GroupItem_GroupAction_1(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Action getGrammarElement() {
		return grammarAccess.getGroupItemAccess().getGroupAction_1();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new GroupItem_GroupKeyword_0(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

    @Override
	public IEObjectConsumer tryConsume() {
		if(!eObjectConsumer.isConsumed()) return null;
		return eObjectConsumer;
	}
}


/************ end Rule GroupItem ****************/


/************ begin Rule NormalItem ****************
 *
 * NormalItem:
 * 	type=("Switch" | "Rollershutter" | "Number" | "String" | "Dimmer" | "Contact" | ID);
 *
 **/

// type=("Switch" | "Rollershutter" | "Number" | "String" | "Dimmer" | "Contact" | ID)
protected class NormalItem_TypeAssignment extends AssignmentToken  {
	
	public NormalItem_TypeAssignment(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Assignment getGrammarElement() {
		return grammarAccess.getNormalItemAccess().getTypeAssignment();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			default: return lastRuleCallOrigin.createFollowerAfterReturn(this, index, index, inst);
		}	
	}

    @Override	
	public IEObjectConsumer tryConsume() {
		if(getEObject().eClass() != grammarAccess.getNormalItemRule().getType().getClassifier())
			return null;
		if((value = eObjectConsumer.getConsumable("type",true)) == null) return null;
		IEObjectConsumer obj = eObjectConsumer.cloneAndConsume("type");
		if(keywordSerializer.isValid(obj.getEObject(), grammarAccess.getNormalItemAccess().getTypeSwitchKeyword_0_0(), value, null)) {
			type = AssignmentType.KEYWORD;
			element = grammarAccess.getNormalItemAccess().getTypeSwitchKeyword_0_0();
			return obj;
		}
		if(keywordSerializer.isValid(obj.getEObject(), grammarAccess.getNormalItemAccess().getTypeRollershutterKeyword_0_1(), value, null)) {
			type = AssignmentType.KEYWORD;
			element = grammarAccess.getNormalItemAccess().getTypeRollershutterKeyword_0_1();
			return obj;
		}
		if(keywordSerializer.isValid(obj.getEObject(), grammarAccess.getNormalItemAccess().getTypeNumberKeyword_0_2(), value, null)) {
			type = AssignmentType.KEYWORD;
			element = grammarAccess.getNormalItemAccess().getTypeNumberKeyword_0_2();
			return obj;
		}
		if(keywordSerializer.isValid(obj.getEObject(), grammarAccess.getNormalItemAccess().getTypeStringKeyword_0_3(), value, null)) {
			type = AssignmentType.KEYWORD;
			element = grammarAccess.getNormalItemAccess().getTypeStringKeyword_0_3();
			return obj;
		}
		if(keywordSerializer.isValid(obj.getEObject(), grammarAccess.getNormalItemAccess().getTypeDimmerKeyword_0_4(), value, null)) {
			type = AssignmentType.KEYWORD;
			element = grammarAccess.getNormalItemAccess().getTypeDimmerKeyword_0_4();
			return obj;
		}
		if(keywordSerializer.isValid(obj.getEObject(), grammarAccess.getNormalItemAccess().getTypeContactKeyword_0_5(), value, null)) {
			type = AssignmentType.KEYWORD;
			element = grammarAccess.getNormalItemAccess().getTypeContactKeyword_0_5();
			return obj;
		}
		if(valueSerializer.isValid(obj.getEObject(), grammarAccess.getNormalItemAccess().getTypeIDTerminalRuleCall_0_6(), value, null)) {
			type = AssignmentType.TERMINAL_RULE_CALL;
			element = grammarAccess.getNormalItemAccess().getTypeIDTerminalRuleCall_0_6();
			return obj;
		}
		return null;
	}

}

/************ end Rule NormalItem ****************/


/************ begin Rule Binding ****************
 *
 * Binding:
 * 	type=ID "=" configuration=STRING;
 *
 **/

// type=ID "=" configuration=STRING
protected class Binding_Group extends GroupToken {
	
	public Binding_Group(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Group getGrammarElement() {
		return grammarAccess.getBindingAccess().getGroup();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Binding_ConfigurationAssignment_2(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

    @Override
	public IEObjectConsumer tryConsume() {
		if(getEObject().eClass() != grammarAccess.getBindingRule().getType().getClassifier())
			return null;
		return eObjectConsumer;
	}

}

// type=ID
protected class Binding_TypeAssignment_0 extends AssignmentToken  {
	
	public Binding_TypeAssignment_0(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Assignment getGrammarElement() {
		return grammarAccess.getBindingAccess().getTypeAssignment_0();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			default: return lastRuleCallOrigin.createFollowerAfterReturn(this, index, index, inst);
		}	
	}

    @Override	
	public IEObjectConsumer tryConsume() {
		if((value = eObjectConsumer.getConsumable("type",true)) == null) return null;
		IEObjectConsumer obj = eObjectConsumer.cloneAndConsume("type");
		if(valueSerializer.isValid(obj.getEObject(), grammarAccess.getBindingAccess().getTypeIDTerminalRuleCall_0_0(), value, null)) {
			type = AssignmentType.TERMINAL_RULE_CALL;
			element = grammarAccess.getBindingAccess().getTypeIDTerminalRuleCall_0_0();
			return obj;
		}
		return null;
	}

}

// "="
protected class Binding_EqualsSignKeyword_1 extends KeywordToken  {
	
	public Binding_EqualsSignKeyword_1(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Keyword getGrammarElement() {
		return grammarAccess.getBindingAccess().getEqualsSignKeyword_1();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Binding_TypeAssignment_0(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

}

// configuration=STRING
protected class Binding_ConfigurationAssignment_2 extends AssignmentToken  {
	
	public Binding_ConfigurationAssignment_2(AbstractToken lastRuleCallOrigin, AbstractToken next, int transitionIndex, IEObjectConsumer eObjectConsumer) {
		super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
	}
	
	@Override
	public Assignment getGrammarElement() {
		return grammarAccess.getBindingAccess().getConfigurationAssignment_2();
	}

    @Override
	public AbstractToken createFollower(int index, IEObjectConsumer inst) {
		switch(index) {
			case 0: return new Binding_EqualsSignKeyword_1(lastRuleCallOrigin, this, 0, inst);
			default: return null;
		}	
	}

    @Override	
	public IEObjectConsumer tryConsume() {
		if((value = eObjectConsumer.getConsumable("configuration",true)) == null) return null;
		IEObjectConsumer obj = eObjectConsumer.cloneAndConsume("configuration");
		if(valueSerializer.isValid(obj.getEObject(), grammarAccess.getBindingAccess().getConfigurationSTRINGTerminalRuleCall_2_0(), value, null)) {
			type = AssignmentType.TERMINAL_RULE_CALL;
			element = grammarAccess.getBindingAccess().getConfigurationSTRINGTerminalRuleCall_2_0();
			return obj;
		}
		return null;
	}

}


/************ end Rule Binding ****************/

}
